<template>
    <div>
        <!-- 把整体看作一个table -->
        <el-col class="el-col">
            <!-- 头部区域 -->
            <div class="colhead">
                <!-- dataUrls包含formName、placeHolder和url三个属性 -->
                <Web_search_box class="row" v-bind:search-req-url="mySearchUrl" :data-urls="myDataUrls" @SearchResult="mySearch"></Web_search_box>
            </div>
        </el-col>

        <!--Result_form @rowClicked="myClickEvent" @rowSelected="HandleSelect" v-bind:type-before="myTypeBefore" v-bind:table-head-json-array="myTableHead" v-bind:addition-btns="myAdditionBtns"></Result_form-->
        <Result_form @rowClicked="myClickEvent" :head-btn="myHeadBtn" :request-u-r-l="baseUrl" :table-head-json-array="myTableHead" :op-base-url="opBaseUrl" :type-before="myTypeBefore" :addition-btns="myAdditionBtns"></Result_form>

    </div>
</template>



<script>
    import Web_search_box from "../components/myUtil/Web_search_box";
    import Result_form from "../components/myUtil/Result_form";
    export default {
        components: {Result_form, Web_search_box},
        data() {
            return {
                mySearchUrl:localStorage.getItem('reqBaseUrl') + '/api/template/search',
                myDataUrls:[{formName:'courseId',placeHolder:'所属课程',url:localStorage.getItem('reqBaseUrl') + '/api/course/search'}],
                opBaseUrl:localStorage.getItem('reqBaseUrl') + '/api/template',
                baseUrl:localStorage.getItem('reqBaseUrl') + '/api/template/search?',
                myTypeBefore:[],
                myHeadBtn:[],
                myTableHead: [{colName:'id',showName:'id',inModel:false},{colName:'name',showName:'模板名称'},
                    {colName: 'course',showName: '所属课程',isJson:true},{colName: 'isEnabled',showName: '审核状态',inModel:false}],
                myAdditionBtns:[{myStyle:'btn btn-success',name:'审核通过'},{myStyle:'btn btn-primary',name:'预览'},{myStyle:'btn btn-danger',name:'锁定'}],
                mySelections:[],
            };
        },
        methods: {
            mySearch(url){
                this.baseUrl = url
            },
            myClickEvent(currentRow,rowId,operation){
                console.log(currentRow,rowId,operation);
                if(operation==='预览'){
                    alert('模板预览')
                }
            }
        }
    };
</script>


<style scoped>
    .colhead {
        padding-bottom: 10px;
        border-bottom: 1px solid #ccc;
    }
</style>
